<?php
function blc_master_irasok_select($from, $itemsPerPage)
{
   $returnValue = query(
      'SELECT 
         t.id    AS id,
         t.title AS title
      FROM text t
      WHERE t.textcategory_id <> 17
      ORDER BY t.modified DESC
      LIMIT :from, :itemsPerPage',
      array('from'=>$from, 'itemsPerPage'=>$itemsPerPage));
   foreach ($returnValue as &$row)
   {
      if (($_GET['p'] === 'cikk') && 
         ($row['id'] == $_GET['id']))
      {
         $row['prefix'] = '<span class="active-href">';
         $row['suffix'] = '</span>';
      } else {
         $row['prefix'] = '';
         $row['suffix'] = '';
      }
   }
   return $returnValue;
}
function blc_master_irasok_select_count()
{
   $returnValue = queryScalar(
   'SELECT COUNT(1)
   FROM text t
   WHERE t.textcategory_id <> 17',
   null);
   return $returnValue;
}

function blc_master_galeriak_select($from, $itemsPerPage)
{
   $returnValue = query(
      'SELECT 
         g.id         AS id,
         g.name      AS name,
         g.gallery_id   AS gallery_id 
      FROM gallery g
      WHERE 
         g.gallery_id IS NOT NULL
      ORDER BY g.name
      LIMIT :from, :itemsPerPage',
      array('from'=>(int)$from, 'itemsPerPage'=>(int)$itemsPerPage));
   foreach ($returnValue as &$row)
   {
        if ( ( ( $_GET['p'] === 'kepgaleria' ) && 
               ( $row['id'] == $_GET['id'] ) ) ||
             ( ( $_GET['p'] === 'kep' ) &&
               ( $row['id'] == $_GET['gal'] ) ) )
      {
         $row['prefix'] = '<span class="active-href">';
         $row['suffix'] = '</span>';
      } else {
         $row['prefix'] = '';
         $row['suffix'] = '';
      }
   }
   return $returnValue;
}

function blc_master_galeriak_select_count()
{
   return queryScalar(
   'SELECT COUNT(1)
   FROM gallery 
   WHERE 
      gallery_id IS NOT NULL',
   null);
}
$master['pageSize'] = 8;
$result = query(
   'SELECT name FROM nameday WHERE month=month(now()) AND day=dayofmonth(now()) ORDER BY id',
   array());
$first = true;
$master['nevnapok'] = '';
foreach ($result as &$nevnap)
{
   if (!$first)
      $master['nevnapok'] .= ', ';
   $master['nevnapok'] .= $nevnap['name'];
   $first = false;
}
$date = getdate();
$master['datum'] = $date['year'].'. '.GetMonthName().' '.$date['mday'].'.';
$master['feastToday'] = queryScalar(
   'SELECT name FROM feast WHERE month_id=month(now()) AND dayofmonth=dayofmonth(now())',
   array());
$colors['text-link'] = queryOneRow('SELECT c.red AS red, c.green AS green, c.blue AS blue FROM color c WHERE c.id = \'text-link\'', null);
$colors['text'] = queryOneRow('SELECT c.red AS red, c.green AS green, c.blue AS blue FROM color c WHERE c.id = \'text\'', null);
$colors['border'] = queryOneRow('SELECT c.red, c.green, c.blue FROM color c WHERE c.id = \'border\'', null);
$master['colors']['text_link'] = sprintf("#%02X%02X%02X", $colors['text-link']['red'], $colors['text-link']['green'], $colors['text-link']['blue']);
$master['colors']['text'] = sprintf("#%02X%02X%02X", $colors['text']['red'], $colors['text']['green'], $colors['text']['blue']);
$master['colors']['border'] = sprintf("#%02X%02X%02X", $colors['border']['red'], $colors['border']['green'], $colors['border']['blue']);
$master['datePicker']['year'] = date("Y");
$master['datePicker']['month'] = (string)(date("m") - 1);
$master['datePicker']['day'] = date("d");
$master['datePicker']['lastDayOfMonth'] = date("t");
$master['layout'] = 'frontend';

?>